package com.gking.processHarvest.common;

import org.apache.shiro.authz.AuthorizationException;
import org.apache.shiro.authz.UnauthorizedException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class PermissionsException {
    @ResponseBody
    @ExceptionHandler(UnauthorizedException.class)
    public Res<String> unauthorizedException(Exception ex) {
        return Res.error("无权限");
    }

    @ResponseBody
    @ExceptionHandler(AuthorizationException.class)
    public Res<String> authorizationException(Exception ex) {
        return Res.error("权限认证失败");
    }

}
